﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Search.aspx.cs" Inherits="TourAgency.Search" ValidateRequest="false"%>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            width: 70%;
        }
        .style2
        {
            width: 102px;
        }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ToolkitScriptManager ID="toolkitSM" runat="server">
    </asp:ToolkitScriptManager>
    <p>
        Search Form:</p>
    <asp:UpdatePanel ID="searchUpdatePanel" runat="server">
        <ContentTemplate>
            <table class="style1">
                <tr>
                    <td class="style2">
                        Destination
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="textBoxDestination" Width="215px"></asp:TextBox>
                        <asp:AutoCompleteExtender ID="AutoCompleteExtenderDestination" runat="server" TargetControlID="textBoxDestination"
                            UseContextKey="True" MinimumPrefixLength="1" ServiceMethod="GetCompletionList"
                            EnableCaching="true">
                        </asp:AutoCompleteExtender>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        Start Date
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="textBoxStartDate" Width="215px" Enabled="false"></asp:TextBox>
                        <asp:CalendarExtender ID="startDateCalendar" runat="server" TargetControlID="textBoxStartDate"
                            Format="MM-dd-yyyy" PopupButtonID="startDateCalendarImg">
                        </asp:CalendarExtender>
                        <asp:Image runat="server" ID="startDateCalendarImg" ImageUrl="~/Styles/images/Calendar.png" />
                        <asp:Button ID="buttonClearStartDate" runat="server" Text="Clear" OnClick="ClearStartDate" />
                </tr>
                <tr>
                    <td class="style2">
                        End Date
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="textBoxEndDate" Width="215px" Enabled="false"></asp:TextBox>
                        <asp:CalendarExtender ID="endDateCalendar" runat="server" TargetControlID="textBoxEndDate"
                            Format="MM-dd-yyyy" PopupButtonID="endDateCalendarImg">
                        </asp:CalendarExtender>
                        <asp:Image runat="server" ID="endDateCalendarImg" ImageUrl="~/Styles/images/Calendar2.png" />
                        <asp:Button ID="buttonClearEndDate" runat="server" Text="Clear" OnClick="ClearEndDate" />
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        Minimum Price
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="textBoxMinPrice" Width="215px"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="MinPriceRegExValidator" runat="server" ErrorMessage="Invalid Minimum Price"
                            ValidationExpression="(0|[1-9]{1}\d*)(\.\d+)?" ControlToValidate="textBoxMinPrice"
                            CssClass="failureNotification">*</asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        Maximum Price
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="textBoxMaxPrice" Width="215px"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="MaxPriceRegExValidator" runat="server" ErrorMessage="Invalid Minimum Price"
                            ValidationExpression="(0|[1-9]{1}\d*)(\.\d+)?" ControlToValidate="textBoxMaxPrice"
                            CssClass="failureNotification">*</asp:RegularExpressionValidator>
                        <asp:CompareValidator ID="PriceCompareValidator" runat="server" ErrorMessage="Max Price must be bigger than Min Price"
                            ControlToCompare="textBoxMaxPrice" ControlToValidate="textBoxMinPrice" CssClass="failureNotification"
                            Operator="LessThan" Type="Double">*</asp:CompareValidator>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        Reference number
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="textBoxRefNumber" Width="215px"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="RefNumberValidator" runat="server" 
                            ErrorMessage="Reference number must conatin only positive numbers" ControlToValidate="textBoxRefNumber" 
                            CssClass="failureNotification" ValidationExpression="[1-9]{1}\d*">*</asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        &nbsp;
                    </td>
                    <td>
                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="failureNotification" />
                        <asp:Button ID="buttonSearch" runat="server" Text="Search" 
                            onclick="buttonSearch_Click" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
